Skip to content

Fix Filament null username crash on impersonate banner#316

Merged
simonhamp merged 1 commit intomainfrom
fix-filament-null-username
Mar 30, 2026
Merged

Fix Filament null username crash on impersonate banner#316
simonhamp merged 1 commit intomainfrom
fix-filament-null-username

Conversation

@simonhamp
Copy link
Copy Markdown
Member

Summary

  • Implements Filament\Models\Contracts\HasName on the User model with a getFilamentName() method
  • Provides a safe fallback chain: display_namenameemail, ensuring a non-null string is always returned
  • Prevents ViewException when the filament-impersonate banner renders for users whose name column is null

Root Cause

Users created via OAuth (e.g. GitHub) can have a null name attribute. When an admin impersonates such a user, the filament-impersonate banner calls FilamentManager::getUserName(), which returns $user->getAttributeValue('name') with a string return type — causing a TypeError.

Closes #48

Test plan

  • Test getFilamentName() returns name when present
  • Test getFilamentName() returns display_name when name is null
  • Test getFilamentName() returns email when both name and display_name are null
  • Test getFilamentName() always returns a string

🤖 Generated with Claude Code

… name

Implement HasName interface on User model with getFilamentName() that
falls back to display_name → name → email, preventing the ViewException
when the filament-impersonate banner renders for users with null names.

Closes #48

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonhamp simonhamp marked this pull request as ready for review March 30, 2026 13:05
@simonhamp simonhamp merged commit 21699ae into main Mar 30, 2026
2 checks passed
@simonhamp simonhamp deleted the fix-filament-null-username branch March 30, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant